﻿var $url = '/account/blacklist';

var data = {
    apiUrl: utils.getQueryString('apiUrl'),
    siteId: utils.getQueryString('siteId'),
    pageLoad: false,
    contents: []
};

var methods = {

    loadPage: function () {
        var $this = this;

        $api.get($url).then(function (response) {
            //获取黑名单
            $this.pageLoad = true;
            $this.contents = response.data;
        });
    },

    btnDeleteClick: function (id, index) {
        var $this = this;
        $url = $url + "/delete/" + id;

        utils.alertDelete({
            title: '移出黑名单',
            text: '此操作将当前用户移出黑名单，确定吗？',
            callback: function () {
                utils.loading(true);
                $api.post($url).then(function (response) {
                    $this.contents.splice(index, 1);
                }).catch(function (error) {
                    
                }).then(function () {
                    utils.loading(false);
                });
            }
        });
    }
};

var $vue = new Vue({
    el: '#main',
    data: data,
    methods: methods,
    computed: {
        getGender: function (idcard) {
            return utils.IdCard(idcard, 2);
        }
    },
    created: function () {
        this.loadPage();
    }
});